﻿using System;


public interface A
{
    double area();
}


public interface B
{
    void setColor(string c);
}


public interface C : A, B
{
    void volume();
}


public class Cylinder : C
{
    // 成员变量
    private double radius;   // 底圆半径
    private double height;   // 圆柱体的高
    private string color;    // 颜色

 
    public Cylinder(double radius, double height)
    {
        this.radius = radius;
        this.height = height;
        this.color = "白色";  // 默认颜色
    }

   
    public double area()
    {
        return Math.PI * radius * radius;
    }


    public void setColor(string c)
    {
        color = c;
    }


    public void volume()
    {
        double vol = area() * height;
        Console.WriteLine($"圆柱体体积: {vol:F2} (底面积: {area():F2}, 高: {height})");
    }


    public void displayInfo()
    {
        Console.WriteLine($"圆柱体信息 - 半径: {radius}, 高: {height}, 颜色: {color}");
    }
}


class Program
{
    static void Main(string[] args)
    {
        // 创建圆柱体对象
        Cylinder cylinder = new Cylinder(3.5, 10.0);

        Console.WriteLine("初始圆柱体:");
        cylinder.displayInfo();
        Console.WriteLine($"底面积: {cylinder.area():F2}");
        cylinder.volume();

        // 设置颜色
        cylinder.setColor("蓝色");
        Console.WriteLine("\n设置颜色后的圆柱体:");
        cylinder.displayInfo();

        // 通过接口C引用圆柱体对象
        C cylinderInterface = new Cylinder(2.0, 5.0);
        Console.WriteLine("\n通过接口C操作的圆柱体:");
        cylinderInterface.setColor("红色");
        Console.WriteLine($"底面积: {cylinderInterface.area():F2}");
        cylinderInterface.volume();
    }
}
